package com.huaxindata.im.model.entity;

public class ChatWarnMessageBody extends ChatMessageBody {

    public String id;
    public String stationCode;
    public String value;
    public String title;
    public String station;
    public String device;
    public String time;


    public ChatWarnMessageBody(int type) {
        super(type);
    }

    /**
     * ID + stationCode + 标志 + 标题 + 站点 + 设施 + 时间
     * @param message
     */
    public void parseWarnMessage(String message) {
        if (message == null) {
            throw new RuntimeException("Invalid type of this message :" + this);
        }
        String[] infos = message.split(ChatMessage.PREX);
        try {
            this.id = infos[0];
            this.stationCode = infos[1];
            this.value = infos[2];
            this.title = infos[3];
            this.station = infos[4];
            this.device = infos[5];
            this.time = infos[6];
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 发送消息拼接
     * @return
     */
    public String matchWarnMessage() {
        return id + ChatMessage.PREX
                + stationCode + ChatMessage.PREX
                + value + ChatMessage.PREX
                + title + ChatMessage.PREX
                + station + ChatMessage.PREX
                + device + ChatMessage.PREX
                + time;
    }

    @Override
    public String toString() {
        return "ChatWarnMessageBody{" +
                "id='" + id + '\'' +
                ", stationCode='" + stationCode + '\'' +
                ", value='" + value + '\'' +
                ", title='" + title + '\'' +
                ", station='" + station + '\'' +
                ", device='" + device + '\'' +
                ", time='" + time + '\'' +
                '}';
    }

}
